<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .triangle1-wrap {
        width: 50px;
        height: 50px;
        overflow: hidden;
      }
      .triangle1 {
        width: 50px;
        height: 50px;
        background-color: red;
        transform: rotateZ(45deg);
        /* 对角线的长度应该大于50*根号2的一半 */
        margin-top: 34px;
      }
      /* left和right相等就是等腰三角形 */
      .triangle2 {
        width: 0px;
        height: 0px;
        border-top: solid 50px green;
        border-bottom: solid 50px transparent;
        border-left: solid 30px transparent;
        border-right: solid 30px transparent;
      }
      /* 四个都相等就是直角三角形 */
      .triangle3 {
        width: 0px;
        height: 0px;
        border-top: solid 50px pink;
        border-bottom: solid 50px transparent;
        border-left: solid 50px transparent;
        border-right: solid 50px transparent;
      }
    </style>
  </head>

  <body>
    <div class="triangle1-wrap">
      <div class="triangle1"></div>
    </div>
    <div class="triangle2"></div>
    <div class="triangle3"></div>
  </body>
</html>
